import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'
import organizationOpt from '@/biz/option/organization.js'

class SearchOpt extends Opt {

  constructor() {
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }


  createAll() {
    let cityAttrSort = [];
    this.all = [
      organizationOpt.create({
        key: 'orgIds'
      }),
      // houseOpt.create({
      //   to: (info) => {
      //     return {
      //       housesId: info.housesId
      //     }
      //   }
      // }),
      {
        key: 'city',
        title: '所属城市',
        load: (o) => {
          organizationOpt.getAreacodePropertyList().then(res => {
            o.cascader.options = res
            cityAttrSort = res
          })
        },
        cascader: {
          options: cityAttrSort,

          loadData(item, callback) {
            console.log(item, 'aaaaaaaaaaa');
            item.loading = true;
            let params = {
              level: 3,
              page: "1",
              parentCode: item.value,
              rows: "100",
            };
            organizationOpt.getAreacodePropertyList2(params).then((res) => {
              res.list.map((itemL) => {
                itemL.value = itemL.cityCode;
                itemL.label = itemL.cityName;
                item.children.push(itemL);
              });

              item.loading = false;
              callback();
            });
            // item.loading = true;
            // let params = {}
            // if (item.level == 2) {
            //   params = {
            //     level: 3,
            //     page: "1",
            //     parentCode: item.cityCode,
            //     rows: "100",
            //   }
            // } else {
            //   params = {
            //     level: 4,
            //     page: "1",
            //     parentCode: item.cityCode,
            //     rows: "100",
            //   }
            // }
            // contractMgr.getAreaList(params).then(res => {
            //   res.map((ele) => {
            //     ele.value = ele.cityCode;
            //     ele.label = ele.cityName;
            //     if (ele.level < 4) {
            //       ele.children = []
            //       ele.loading = false
            //     }
            //     item.children.push(ele)
            //   });
            //   item.loading = false
            //   callback();
            // })
          }
        }
      },

      {
        title: '案场名字',
        placeholder: '',
        key: 'housesName',
        // select: {
        //   key: 'buildStatus',
        //   clearable: true
        // }
        input: {}
      },
      {
        title: '状态',
        placeholder: '选择审核结果',
        key: 'status',
        // select: {
        //   key: 'buildStatus',
        //   clearable: true
        // }
        select: {
          options: [
            { key: '1', value: '未补' },
            { key: '2', value: '已补' },
          ]
        }
      },
    ]
  }
}

export default SearchOpt